package com.yinet.web.controller.wsyy;

import com.yinet.common.annotation.Log;
import com.yinet.common.core.controller.BaseController;
import com.yinet.common.core.domain.AjaxResult;
import com.yinet.common.core.page.TableDataInfo;
import com.yinet.common.enums.BusinessType;
import com.yinet.common.utils.poi.ExcelUtil;
import com.yinet.wsyy.domain.Wsyy;
import com.yinet.wsyy.service.IWsyyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 网上预约列表Controller
 *
 * @author yinet
 * @date 2019-09-02
 */
@Controller
@RequestMapping("/wsyy/wsyy")
public class WsyyController extends BaseController {
    private String prefix = "wsyy/admin";

    @Autowired
    private IWsyyService wsyyService;

    @GetMapping()
    public String wsyy() {
        return prefix + "/wsyy";
    }

    /**
     * 查询网上预约列表列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Wsyy wsyy) {
        startPage();
        List<Wsyy> list = wsyyService.selectWsyyList(wsyy);
        return getDataTable(list);
    }

    /**
     * 导出网上预约列表列表
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Wsyy wsyy) {
        List<Wsyy> list = wsyyService.selectWsyyListExcel(wsyy);
        ExcelUtil<Wsyy> util = new ExcelUtil<Wsyy>(Wsyy.class);
        return util.exportExcel(list, "wsyy");
    }

    /**
     * 删除网上预约列表
     */
    @Log(title = "网上预约列表", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(wsyyService.deleteWsyyByIds(ids));
    }
}
